<?php
namespace Home\Controller;
use Common\Model\AgeModel;
use Common\Model\CalculateDays;
use Common\Model\CalculatedDays;
use Think\Controller;
class CarlistController extends Controller{
     /*车列表显示界面，并充当着HomePage的Action界面*/
    public  function  carlist(){
        if(empty($_SESSION)){$this->error("您还未登录,为您转到登录界面","/Login/Login");}
        /*创建会员用户的工厂*/
        $Mem = null;
        $MemFactory = D('Mem');
        $Mem = $MemFactory->fetch($_SESSION['Mem']);
        $this->assign("Mem",$Mem);
        /*创建车的工厂*/
        $Car = null;
        $CarFactory = D('Car');
        $Car = $CarFactory->select();
        $this->assign("Car",$Car);

        /*从HomePage传过来的数据*/
        $data = null;
        if($_POST['fetchTime']==null||$_POST['fetchHour']==null||
            $_POST['backTime']==null||$_POST['backHour']==null||
            $_POST['fetchPlace']==null||$_POST['backPlace']==null)
            $this->error('所填信息不能为空，请重新选择');
        else{

            $CalculatedDays = new CalculatedDays();
            $orderDays = $CalculatedDays->orderDays($_POST);


            $_SESSION['fetchTime'] = $_POST['fetchTime'];
            $_SESSION['fetchHour'] = $_POST['fetchHour'];
            $_SESSION['backTime'] = $_POST['backTime'];
            $_SESSION['backHour'] = $_POST['backHour'];
            $_SESSION['fetchPlace'] = $_POST['fetchPlace'];
            $_SESSION['backPlace'] = $_POST['backPlace'];
            $_SESSION['orderDays'] = $orderDays;

            $this->assign('data',$_SESSION);
            $this->display('carlist');
        }
    }
}